package com.lanfan.controller.admin;

import com.lanfan.entity.Notes;
import com.lanfan.entity.ResponseResult;
import com.lanfan.service.NotesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: lanfan
 * @parameter:
 * @return：
 * @description:
 * @author: WXP
 * @create: 2024-10-11 15:57
 * @version: 1.0
 **/
@RestController
@RequestMapping("/admin/notes")
public class NotesController {
    @Resource
    private NotesService notesService;

    @PostMapping("/create")
    public ResponseResult createNote(@RequestBody Notes note){
        notesService.createNote(note);
        ResponseResult responseResult = new ResponseResult();
        return responseResult;
    }

    @DeleteMapping("/delete/{noteid}")
    public ResponseResult delete(@PathVariable String noteid) {
        notesService.deleteNote(noteid);
        ResponseResult responseResult = new ResponseResult();
        return responseResult;
    }

    @PostMapping("/getNoteByUserId")
    public ResponseResult getNoteByUserId(@RequestBody Notes note){
        List<Notes> list =notesService.getNoteByUserId(note.getUserId().toString());
        ResponseResult responseResult = new ResponseResult();
        responseResult.setDate(list);
        return responseResult;
    }
}
